export default {
    inject: {
        getExtendValue:{
            default(){
                return ()=>{}
            }
        },
        updateExtend:{
            default(){
                return ()=>{}
            }
        },
    },
    data(){
        return {
            __oldData:undefined,
            __update:true,
            __firstUpdate:true
        }
    },
    watch:{
        disabled:{
            handler(val){
               if (val){
                   this.__oldData = JSON.parse(JSON.stringify(this.form));
                   this.$assign(this.form,this.defaultData);
               }else{
                   let value = this.getExtendValue(this.app,this.power);
                
                   if (this.__oldData) {
                       this.$assign(this.form,this.__oldData);
                   }else{
                       if (value!=undefined) this.$assign(this.form,value);
                   }

                   if (value==undefined){
                       this.updateExtend(this.app,this.power,this.form);
                   }
               }           
           },
           immediate: true,
        },
        form:{
            handler(val){
                if (this.__update){
                     this.updateExtend(this.app,this.power,val);
                }else{
                    this.__update = true;
                }           
            },
            deep:true
        }
    },
    methods:{
        getUserValue(name){

        }
    },
    props:{
        app:String,
        power:String,
        disabled:Boolean,    
        defaultData:Object,
        userData:Object,
    }
}